home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / UTILITY / MXMNU238 / TMAX.MNU < prev    next >
Text File  |  1992-03-09  |  12KB  |  513 lines

  1. Comment
  2. ================================================
  3.  
  4. MarxMenu TaskMax Interface.
  5. Copyright 1992 by Marc Perkel * All Rights Reserved
  6. This menu requires DR-DOS 6.0 and TaskMax to run.
  7.  
  8. This example was designed to work with programs I have. It can be
  9. easilly reconfigured to work with your programs. It may be more
  10. elaborate than what you need.
  11.  
  12. To start this menu run MARXMENU TMAX.
  13.  
  14. This menu has many advantages over the default TaskMax menu. One is that
  15. it is much more flexable. Not only can you start a command line but you
  16. can start applications as well.
  17.  
  18. This menu also gives you the ability to preload tasks so that they are
  19. ready to be switched to. It also gives you the ability to set up timed
  20. execution; running a program and comming back to the menu automatically.
  21.  
  22. It can also allow you to manage the paste buffer. You can view it or
  23. pre-load it with anything you want. This menu can be modified to allow
  24. you to save paste buffers in a stack for later retrieval.
  25.  
  26. It also helps you retain your network security. The TaskMax menu only
  27. allows you to start a command line. Under MarxMenu you can restrict
  28. users from the command line and completely control the task switcher
  29. globally. Different users might have different menu options depending on
  30. what Novell groups they're in.
  31.  
  32. By using the screen blanker and automatic logoff features built into
  33. MarxMenu network security features are enhanced. The user can at any
  34. point switch to this menu and activate the screen blanker. The options
  35. in TMAX.INC can be set to require a password to unblank the screen.
  36.  
  37. ================================================
  38. EndComment
  39.  
  40.  
  41. Var
  42.   Tasks
  43.   NameList
  44.   ChoiceCount
  45.   UnLoad
  46.   MyTask
  47.   NukeMe
  48.   StatWin
  49.   FilePicked
  50.   LastTask
  51.   PickChoices
  52.  
  53. Qualifier
  54.   TaskName
  55.   TaskID
  56.  
  57. ;----- Get out if not running TaskMax
  58.  
  59. if not TMaxInstalled
  60.    StandardIO
  61.    Writeln
  62.    Writeln 'Requires DR-DOS TaskMax to Run!'
  63.    ExitMenu
  64. endif
  65.  
  66.  
  67. StatusLineText = '*-<< Acme Manufacturing Company >>-*'
  68. MenuTitle = "Joe Blow's Pop Up Menu"
  69.  
  70. Include 'TMAX.INC'
  71.  
  72. Setup
  73. Main
  74. ExitMenu
  75.  
  76. ;================================================
  77.  
  78. Procedure Select
  79. var Ch H P X Y W Indent MaxSingleColumn
  80.  
  81.    MaxSingleColumn = 5
  82.  
  83.    OnScreenOnly
  84.    BuildChoices
  85.    Status
  86.  
  87.    Explode Off
  88.    H = ChoiceCount
  89.    Indent = ''
  90.    W = 29
  91.    if ChoiceCount > MaxSingleColumn
  92.       H = ChoiceCount + 1 / 2
  93.       Indent = ' '
  94.       W = 32
  95.    endif
  96.    H = H + 8 + HeightDifference
  97.    if ChoiceCount = 0 then H = H - 1
  98.    DrawTheBox (5,(ScreenHeight - H) / 2 + 2,W,H,'MarxMenu TaskMax Menu')
  99.    Explode On
  100.    CapsColor(MenuCapColorFG,MenuBG)
  101.  
  102.    Loop Choices
  103.       if ChoiceCount > MaxSingleColumn
  104.          X = 1
  105.          if LoopIndex mod 2 = 0 then X = 14
  106.          Y = LoopIndex - 1 / 2 + 1
  107.          GotoXY X Y
  108.       endif
  109.       Writeln Choices[LoopIndex]
  110.    EndLoop
  111.    if ChoiceCount > 0
  112.       TextColor MenuVertLinesFG MenuBG
  113.       ClearLine '─'
  114.       Writeln
  115.       TextColor MenuInsideFG MenuBG
  116.       CapsColor(MenuCapColorFG,MenuBG)
  117.    endif
  118.  
  119.    if LastTask > TMaxMaxTasks then LastTask = 0
  120.    if ChoiceCount = 1 then LastTask = 1
  121.    if ChoiceCount = 0 then Suggest '1'
  122.    if LastTask > 0
  123.       Suggest Char(LastTask + 64)
  124.    endif
  125.  
  126.    Writeln Indent '  1 - New Command Line'
  127.    Writeln Indent '  2 - Directory Master'
  128.    Writeln Indent '  3 - Type in a Command'
  129.    Writeln Indent '  4 - TaskMax Control'
  130.    Writeln Indent '  5 - Delete a Task'
  131.    Writeln Indent '  6 - Applications'
  132.    Write   Indent '  U - Unload This Menu'
  133.  
  134.    Ch = ReadKey
  135.  
  136.    if (Ch >= 'A') and (Ch <= Char(ChoiceCount + 64))
  137.       SwitchTasks(Tasks[(ord(Ch) - 64)].TaskID)
  138.  
  139.    elseif Ch = '1'
  140.       if ExistOnPath('DOLIST.EXE') > ''
  141.          CreateTask('DOLIST.EXE')
  142.       else
  143.          CreateTask('COMMAND')
  144.       endif
  145.  
  146.    elseif Ch = '2'
  147.       P = PosInList('DM3',NameList)
  148.  
  149.       ;----- If DM3 is running the select it else start a new one
  150.  
  151.       if P = 0
  152.          CreateTask('DM3.EXE')
  153.       else
  154.          SwitchTasks(Tasks[P].TaskID)
  155.       endif
  156.  
  157.    elseif Ch = '3'
  158.       TypeACommand
  159.  
  160.    elseif Ch = '4'
  161.       SetOptions
  162.  
  163.    elseif Ch = '5'
  164.       KillTasks
  165.  
  166.    elseif Ch = '6'
  167.       Applications
  168.       EraseTopWindow
  169.  
  170.    elseif Ch = 'U'
  171.       Unload = True
  172.  
  173.    elseif Ch = ESC
  174.       if ChoiceCount = 0
  175.          Unload = True
  176.       else
  177.          if LastTask > 0
  178.             SwitchTasks(Tasks[LastTask].TaskID)
  179.          endif
  180.       endif
  181.  
  182.    endif
  183.    EraseTopWindow
  184. EndProc
  185.  
  186.  
  187. Procedure Main
  188.    TMaxTakeOver On
  189.    while not Unload
  190.       Select
  191.    EndWhile
  192.    TMaxTakeOver Off
  193. EndProc
  194.  
  195.  
  196. Procedure TypeACommand
  197. var St
  198.    DrawBox 10 21 60 3
  199.    TextColor MenuHeaderFG MenuBG
  200.    Write ' Type Command: '
  201.    TextColor MenuInsideFG MenuBG
  202.    St = Readln
  203.    EraseTopWindow
  204.    if St > ''
  205.       CreateTask(St)
  206.    endif
  207. EndProc
  208.  
  209.  
  210. Procedure DrawPickTasksBox (Msg)
  211. var T
  212.    PickChoices = Choices
  213.    T = ScreenHeight - ChoiceCount / 2
  214.    DrawTheBox (29,T,19,ChoiceCount + HeightDifference,Msg)
  215.    Loop PickChoices
  216.       Trim(PickChoices[LoopIndex])
  217.    EndLoop
  218. EndProc
  219.  
  220.  
  221. Procedure KillTasks
  222. var Ch ID KillList T FileString Name
  223.    DrawPickTasksBox('Kill Tasks')
  224.    PickMany(PickChoices,KillList)
  225.    EraseTopWindow
  226.    Loop PickManyPositions
  227.       Name = Tasks[PickManyPositions[LoopIndex]].TaskName
  228.       ID = Tasks[PickManyPositions[LoopIndex]].TaskID
  229.       T = TMaxTaskOpenFiles(ID)
  230.       DrawBox 27 10 19 + length(Name) 3
  231.       TextColor MenuHeaderFG MenuBG
  232.       Write ' Deleting Task: '
  233.       TextColor MenuInsideFG MenuBG
  234.       Write Name
  235.       if T > 0
  236.          FileString = 'Files'
  237.          if T = 1 then FileString = 'File'
  238.          FileString = Str(T) + ' open ' + FileString
  239.          if AskYesNo ('Task has ' + FileString +'. Delete Anyway?')
  240.             TMaxDeleteTask(ID)
  241.          endif
  242.       else
  243.          Wait 250
  244.          TMaxDeleteTask(ID)
  245.       endif
  246.       EraseTopWindow
  247.    EndLoop
  248.    LastTask = 0
  249. EndProc
  250.  
  251.  
  252. Procedure CreateTask (Cmd)
  253.    TMaxCreateTask(Cmd)
  254.    LastTask = TMaxTaskIndex(TMaxResult);
  255. EndProc
  256.  
  257.  
  258. Procedure SwitchTasks (T)
  259.    TMaxSwitchTasks(T)
  260.  
  261.    ;TMaxSwitchTasks returns the TaskID of the last active task in TMaxResult
  262.  
  263.    LastTask = TMaxTaskIndex(TMaxResult);
  264. EndProc
  265.  
  266.  
  267. Procedure SwitchTaskByName (Name)
  268.    SwitchTasks(Tasks[PosInlist(Name,NameList)].TaskID)
  269. EndProc
  270.  
  271.  
  272. Procedure Setup
  273.  
  274.    BuildChoices
  275.  
  276.    ;----- AutoLoad Tasks
  277.  
  278.    ;----- Only load DM3.EXE if not already loaded
  279.  
  280.    if (PosInList('DM3',NameList) = 0) and (ExistOnPath('DM3.EXE') > '')
  281.       TMaxReturnCount = 40
  282.       CreateTask('DM3.EXE')
  283.    endif
  284.  
  285.    ;----- Only load SideKick 2 if not already loaded
  286.  
  287.    if (PosInList('SK2',NameList) = 0) and ExistFile('H:\SK2\SKCONFIG.SKC')
  288.       TMaxReturnCount = 200
  289.       CreateTask('SK2.BAT')
  290.    endif
  291.  
  292.    TMaxReturnCount = 0
  293.    DrawTheBox (42,ScreenHeight / 2 - 2,32,HeightDifference + 4,'TaskMax Status')
  294.    StatWin = CurrentWindow
  295.  
  296. EndProc
  297.  
  298. ;----- Show Status Information
  299.  
  300. Procedure Status
  301.    SetTopWindow StatWin
  302.    TextColor MenuInsideFG MenuBG
  303.    Writeln '    Maximum Tasks: ' TMaxMaxTasks
  304.    Writeln '     Active Tasks: ' ChoiceCount ' '
  305.    Writeln ' EMS Memory Limit: ' TMaxEMSMemLim / 1024 'k   '
  306.    Write   '  Free Disk Space: ' FreeDiskSpace Path / 1000000 'm  '
  307.    if StatWin < CurrentWindow
  308.       SetWindowUnder (StatWin,StatWin + 1)
  309.    endif
  310. EndProc
  311.  
  312. ;----- This code reads the task list and processes the choices.
  313.  
  314. Procedure NewChoice (Num,St)
  315.    AppendArray(Choices,'  ' + Char(Num + 64) + ' - ' + St)
  316. EndProc
  317.  
  318.  
  319. Procedure BuildChoices
  320.    MyTask = TMaxThisTask
  321.    TMaxReadTaskInfo (Tasks)
  322.  
  323.    Dispose(Choices)
  324.    Dispose(NameList)
  325.    ChoiceCount = 0
  326.  
  327.    Loop Tasks
  328.       if Tasks[LoopIndex].TaskID = MyTask
  329.          NukeMe = LoopIndex
  330.       else
  331.          ChoiceCount = ChoiceCount + 1
  332.          NewChoice(ChoiceCount,Tasks[LoopIndex].TaskName)
  333.          AppendArray(NameList,Tasks[LoopIndex].TaskName)
  334.       endif
  335.    EndLoop
  336.  
  337.    ;don't show the task switcher task in the task list
  338.  
  339.    delete(Tasks,NukeMe,1)
  340. EndProc
  341.  
  342.  
  343. Procedure IsLoaded (Name)
  344.    Return PosInList(Name,NameList) > 0
  345. EndProc
  346.  
  347.  
  348. Procedure SetOptions
  349. var Ch St PB CurrentBuffer
  350.    DrawTheBox (23,ScreenHeight / 2 + 1,29,HeightDifference + 6,'TaskMax Options')
  351.    Writeln '  A - Direct Switching'
  352.    Writeln '  B - EMS Memory Limit'
  353.    Writeln '  C - Copy Data'
  354.    Writeln '  D - Paste Data'
  355.    Writeln '  E - View Paste Buffer'
  356.    Write   '  F - Paste my Address'
  357.  
  358.    While Ch <> Esc
  359.  
  360.       Ch = ReadKey
  361.  
  362.       if Ch = 'A'
  363.          TMaxDirectSwitching = AskYesNo('Allow use of Direct Switch Keys?')
  364.  
  365.  
  366.       elseif Ch = 'B'
  367.          DrawBox 25 22 31 3
  368.          TextColor MenuHeaderFG MenuBG
  369.          Write ' EMS Memory Limit (k): '
  370.          TextColor MenuInsideFG MenuBG
  371.          St = Readln
  372.          EraseTopWindow
  373.          TMaxEMSMemLim = Value(St) * 1024
  374.  
  375.       elseif Ch = 'C'
  376.          Cut
  377.  
  378.       elseif Ch = 'D'
  379.          Paste
  380.  
  381.       elseif Ch = 'E'
  382.          ViewPasteBuffer
  383.  
  384.       elseif Ch = 'F'
  385.          Dispose(PB)
  386.          AppendArray(PB,'Computer Tyme')
  387.          AppendArray(PB,'411 North Sherman Suite 300')
  388.          AppendArray(PB,'Springfield MO. 65802')
  389.          AppendArray(PB,'417-866-1222')
  390.  
  391.          ;save and restore current paste buffer
  392.  
  393.          TMaxGetPasteBuffer(CurrentBuffer)
  394.          TMaxSetPasteBuffer(PB)
  395.          Paste
  396.          TMaxSetPasteBuffer(CurrentBuffer)
  397.  
  398.       endif
  399.  
  400.    endwhile
  401.  
  402.    EraseTopWindow
  403. EndProc
  404.  
  405.  
  406. Procedure Cut
  407. var C
  408.    DrawPickTasksBox('Cut from Task')
  409.    C = PickOne(PickChoices)
  410.    EraseTopWindow
  411.    if PickPosition <> 0
  412.       TMaxCut(Tasks[PickPosition].TaskID)
  413.    endif
  414. EndProc
  415.  
  416.  
  417. Procedure Paste
  418. var C
  419.    DrawPickTasksBox('Paste to Task')
  420.    C = PickOne(PickChoices)
  421.    EraseTopWindow
  422.    if PickPosition <> 0
  423.       TMaxPaste(Tasks[PickPosition].TaskID)
  424.    endif
  425. EndProc
  426.  
  427.  
  428. Procedure ViewPasteBuffer
  429. var Paste
  430.    BoxHeader = ' Viewing Paste Buffer '
  431.    Shadow Off
  432.    DrawBox 1 4 ScreenWidth ScreenHeight - 4
  433.    TextColor MenuHeaderFG MenuBG
  434.    TMaxGetPasteBuffer(Paste)
  435.    ViewArray(Paste)
  436. EndProc
  437.  
  438.  
  439. ;----- Applications Menu
  440.  
  441. Procedure Applications
  442.  
  443.    Dispose Choices
  444.  
  445.    AddChoice('Pick Directory',1)
  446.    AddChoice('TapCIS',2)
  447.    AddChoice('Telemate',3)
  448.  
  449.    CenterStretchBox ('DOS Menu',38,15)
  450.  
  451.    LastKey = UpperCase(ReadKey)
  452.  
  453.    while True
  454.  
  455.       if LastKey = Task(1)
  456.          CreateTask('PD.EXE')
  457.          Return
  458.  
  459.       elseif LastKey = Task(2)
  460.  
  461.          ; only load TapCis once
  462.  
  463.          if IsLoaded('TAPCIS')
  464.             SwitchTaskByName('TAPCIS')
  465.          else
  466.             CreateTask('CIS')
  467.          endif
  468.          Return
  469.  
  470.       elseif LastKey = Task(3)
  471.  
  472.          ; only load Telemate once
  473.  
  474.          if IsLoaded('TM')
  475.             SwitchTaskByName('TM')
  476.          else
  477.             CreateTask('TM')
  478.          endif
  479.          Return
  480.  
  481.       elseif LastKey = Esc
  482.          Return
  483.  
  484.       endif
  485.  
  486.    EndWhile
  487.  
  488. EndProc
  489.  
  490.  
  491. Procedure AskYesNo (Question)
  492. var YesNo
  493.    DrawBox(34 - (Length(Question) / 2),21,Length(Question) + 14,3)
  494.    TextColor MenuHeaderFG MenuBG
  495.    UseArrows Off
  496.    Cursor On
  497.    Write ' ' Question ' (Y/N) '
  498.    YesNo = UpperCase(ReadKey)
  499.    YesNo = YesNo = 'Y'
  500.    TextColor MenuInsideFG MenuBG
  501.    if YesNo
  502.       Write 'Yes'
  503.    else
  504.       Write 'No'
  505.    endif
  506.    Wait 50
  507.    EraseTopWindow
  508.    UseArrows On
  509.    Return YesNo
  510. EndProc
  511.  
  512.  
  513.